home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_9.lha / 7_9 / 7_9_getp.c < prev    next >
Text File  |  1993-08-08  |  516b  |  34 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Get the previous entry from a list,
  6. / removing it afterwards
  7. nt dlist::getprev(dlink *&a)
  8.  
  9.    if (!last)
  10. return 0;
  11.  
  12.    // choose the link to remove
  13.    if (curr)
  14. if (curr == last->prev)
  15.     {
  16.     curr = 0;
  17.     return 0;
  18.     }
  19.  
  20. else
  21.     a = curr->prev;
  22.  
  23.    else
  24. a = curr = last;
  25.  
  26.    // remove f from the list
  27.    if (a == last)
  28. last = 0;
  29.  
  30.    else
  31. a->remove();
  32.    return 1;
  33.  
  34.